define(['app'], function(app) {
    app.controller('RegexDebuggerController', function Controller() {
        var that = this;
        
        that.params = {
            content: '',
            regex: '',
            mode: '0'
        };
        that.executeResult = '';
        
        that.executeRegex = function(valid) {
            if (valid) {
                var pattern = new RegExp(that.params.regex, "gm");
                if (that.params.mode == '0') {
                    that.executeResult = that.params.content.match(pattern);
                } else {
                    that.executeResult = that.params.content.replace(pattern, '');
                }
            }
        };
        
        that.clearAll = function() {
            that.params = {
                content: '',
                regex: '',
                mode: '0'
            };
            that.executeResult = '';
        };
    });
});
